﻿using Alipay.AopSdk.Core;
using Alipay.AopSdk.Core.Domain;
using Alipay.AopSdk.Core.Request;
using Alipay.AopSdk.Core.Response;
using Alipay.AopSdk.Core.Util;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZhouYu.DreamTour.BLL.IService;
using ZhouYu.DreamTour.Model;
using ZhouYu.DreamTour.ViewModel;
using ZhouYu.DreamTour.ViewModel.AlipayOrder;
using ZhouYu.DreamTour.Web.Models;

namespace ZhouYu.DreamTour.Web.Controllers
{
    public class UserController : Controller
    {
        private ISmsInfoService _smsInfoService;
        private IUserService _userService;
        public UserController(ISmsInfoService smsInfoService, IUserService userService)
        {
            _smsInfoService = smsInfoService;
            _userService = userService;
        }


        /// <summary>
        /// 用户手机注册
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult AddUserInfo(UserInfo userInfo)
        {
            //调用用户手机注册
            ResponseResult responseResult =_userService.AddUserInfo(userInfo);
            return Json(responseResult);
        }

        /// <summary>
        /// 用户邮箱注册
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult AddUserEmailInfo(UserInfo userInfo)
        {
            //调用用户邮箱注册
            ResponseResult responseResult = _userService.AddUserEmailInfo(userInfo);
            return Json(responseResult);
        }


        /// <summary>
        /// 查询邮箱验证码是否存在
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult CheckEmailCode(EmailInfo emailInfo)
        {
            //调用查询邮箱验证码是否存在
            ResponseResult responseResult = _userService.CheckEmailCode(emailInfo);
            return Json(responseResult);
        }

        /// <summary>
        /// 查询邮箱是否存在
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult CheckUser_Email(UserInfo userInfo)
        {
            //调用查询邮箱是否存在
            ResponseResult responseResult = _userService.CheckUser_Email(userInfo);
            return Json(responseResult);
        }

        /// <summary>
        /// 查询手机号
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult CheckUserTel(UserInfo userInfo)
        {
            //调用查询手机号
            ResponseResult responseResult =_userService.CheckUserTel(userInfo);
            return Json(responseResult);
        }

        /// <summary>
        /// 添加短信发送记录
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult AddSmsInfoRegister(string tel)
        {
            //调用添加短信发送记录
            ResponseResult responseResult = _smsInfoService.AddSmsInfo(tel);
            return Json(responseResult);
        }


        /// <summary>
        /// 发送邮箱验证码
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult SendEmailCode(string email)
        {
            //调用发送邮箱验证码方法
            ResponseResult responseResult = _userService.SendEmailCode(email);
            return Json(responseResult);
        }


        /// <summary>
        /// 检查验证码
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult CheckCodeRegister(SmsInfo smsInfo)
        {
            //调用检查验证码
            ResponseResult responseResult =_smsInfoService.CheckCode(smsInfo);
            return Json(responseResult);
        }


        /// <summary>
        /// 选择抵用卷充值
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult UserRecharge(Model.Voucher voucher)
        {
            //调用根据主键id查询抵用居面额
            ResponseResult responseResult = _userService.GetVoucherByKey(voucher.Voucher_Id);
            //获取抵用卷面额
            Model.Voucher vou = responseResult.data;
            decimal? voucherMoney = vou.Voucher_balance;
            //查询当前登录用户余额
            responseResult = _userService.GetUserById(voucher.User_Id);
            //获取用户抵用卷余额
            UserInfo user = responseResult.data;
            decimal? userMoney = user.User_VoucherCount;
            //抵用卷面额和用户抵用卷余额相加得到充值后的余额
            decimal? sumMoney = voucherMoney + userMoney;
            //修改抵用卷状态
            vou.Voucher_Id = voucher.Voucher_Id;
            vou.Voucher_State = 0;
            responseResult = _userService.EditVoucherState(vou);
            if (!responseResult.Success) 
            {
                return Json(responseResult);
            }
            //修改用户抵用卷余额
            user.User_VoucherCount = sumMoney;
            responseResult = _userService.EditUserVoucher(user);
            return Json(responseResult);
        }


        /// <summary>
        /// 选择旅游卷充值
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult TourVoRecharge(Travelvo travelvo)
        {
            //校验密码是否正确
            ResponseResult responseResult = _userService.CheckTravelVoPwd(travelvo);
            if (responseResult.Success)
            {
                //获取抵用卷面额
                Travelvo travo1 = _userService.GetTravelVoByKey(travelvo.TravelVo_Id).data;
                decimal? travelVoMoney = travo1.TravelVo_balance;
                //查询当前登录用户余额
                responseResult = _userService.GetUserById(travelvo.User_Id);
                //获取用户抵用卷余额
                UserInfo user = responseResult.data;
                decimal? userMoney = user.User_TravelVoCount;
                //抵用卷面额和用户抵用卷余额相加得到充值后的余额
                decimal? sumMoney = travelVoMoney + userMoney;
                //修改旅游卷状态
                travo1.TravelVo_Id = travelvo.TravelVo_Id;
                travo1.TravelVo_State = 0;
                responseResult = _userService.EditTravelVoState(travo1);
                if (!responseResult.Success)
                {
                    return Json(responseResult);
                }
                //修改用户卷余额
                user.User_TravelVoCount = sumMoney;
                responseResult = _userService.EditUserTravelVo(user);
                if (responseResult.Success)
                {
                    responseResult.msg = "充值成功！";
                }
                else 
                {
                    responseResult.msg = "充值失败！";
                }
            }
            else 
            {
                responseResult.msg = "密码错误";
            }
            return Json(responseResult);
        }

        /// <summary>
        /// 修改当前用户密码
        /// </summary>
        /// <returns></returns>
        public JsonResult Changepwd(string Pwd, int  UserId)
        {
            //调用修改密码
            ResponseResult responseResult = new ResponseResult();
            responseResult.Success = _userService.Changepwd(Pwd,UserId)>0;
            return Json(responseResult,JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 获取地址列表
        /// </summary>
        /// <returns></returns>
        public JsonResult AddressesList(int page,int limit,int UserId)
        {
            List<DeliveryAddress> list = _userService.AddressList(UserId);
            int count = 0;
            PageListResult<DeliveryAddress> pageListresult = new PageListResult<DeliveryAddress>();
            pageListresult.code = 0;
            pageListresult.msg = "";
            pageListresult.count = count;
            pageListresult.data = list.Skip((page - 1) * limit).Take(limit).ToList();
            return Json(pageListresult, JsonRequestBehavior.AllowGet);
        }


        /// <summary>
        /// 根据Id删除地址
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public JsonResult DeleteAddress(int Id)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.Success = _userService.DeleteAddress(Id)>0;
            return Json(responseResult, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 添加新地址
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public JsonResult AddAddress(DeliveryAddress address)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.Success = _userService.AddAddress(address) > 0;
            return Json(responseResult, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 修改地址
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public JsonResult UpdateAddress(DeliveryAddress address)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.Success = _userService.UpdateAddress(address) > 0;
            return Json(responseResult, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 修改地址状态
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public JsonResult Modifyaddressstatus(int Id)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.Success = _userService.Modifyaddressstatus(Id)> 0;
            return Json(responseResult, JsonRequestBehavior.AllowGet);
        }
        //修改地址状态全部为0
        public JsonResult UpdateAlladdressStates(int UserId)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.Success = _userService.UpdateAlladdressStates(UserId)> 0;
            return Json(responseResult, JsonRequestBehavior.AllowGet);
        }


        /// <summary>
        /// 查询用户积分
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="Createtime"></param>
        /// <param name="Effective"></param>
        /// <param name="User_Id"></param>
        /// <returns></returns>
        public JsonResult IntegralList(int page, int limit, string Createtime, string Effective, int User_Id)
        {

            List<Custompoints> list = _userService.IntegralList(Createtime, Effective, User_Id);
            int count = 0;
            PageListResult<Custompoints> pageListresult = new PageListResult<Custompoints>();
            pageListresult.code = 0;
            pageListresult.msg = "";
            pageListresult.count = count;
            pageListresult.data = list.Skip((page - 1) * limit).Take(limit).ToList();
            return Json(pageListresult, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 发送申请结伴同行
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult AddColleague(ColleagueInfo colleagueInfo)
        {
            //获取人数集合
            List<Number> numbers = colleagueInfo.NumberList;
            //给时间赋值
            for (int i = 0; i < numbers.Count; i++)
            {
                numbers[i].Number_UpdateTime = DateTime.Now;
                numbers[i].Number_CreateTime = DateTime.Now;
            }
            //获取发起人信息表对象
            Originator originator = colleagueInfo.Originator;
            originator.Originator_CreateTime = DateTime.Now;
            originator.Originator_UpdateTime = DateTime.Now;

            //获取结伴同行表信息
            Colleague colleague = new Colleague();
            colleague.User_Id = UserInfoContext.userInfoContext.UserInfo.User_Id;
            colleague.Route_Id = colleagueInfo.Route_Id;
            colleague.Colleague_Title = colleagueInfo.Colleague_Title;
            colleague.Colleague_OutingTime = colleagueInfo.Colleague_OutingTime;
            colleague.Colleague_PaymentMethod = colleagueInfo.Colleague_PaymentMethod;
            colleague.Colleague_CreateTime = DateTime.Now;
            colleague.Colleague_UpdateTime = DateTime.Now;

            //调用添加发起人信息表
            ResponseResult responseResult = _userService.AddOriginator(originator);
            if (responseResult.Success)
            {
                //获取发起人信息表主键
                Originator ori = _userService.GetOriginatorLast().data;
                colleague.Originator_Id = ori.Originator_Id;
                //添加结伴同行表
                responseResult = _userService.AddColleague(colleague);
                //判断是否成功
                if (responseResult.Success)
                {
                    //获取结伴同行表主键
                    Colleague coll = _userService.GetColleagueLast().data;
                    for (int i = 0; i < numbers.Count; i++)
                    {
                        numbers[i].Colleague_Id = coll.Colleague_Id;
                    }
                    //添加结伴同行人数表
                    responseResult = _userService.AddNumbers(numbers);
                }
            }
            return Json(responseResult);
        }

        /// <summary>
        /// 查询用户已点评
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public JsonResult Querycomment(int page, int limit, int userId)
        {
            List<Usercomment> list = _userService.Querycomment(userId);
            int count = 0;
            PageListResult<Usercomment> pageListresult = new PageListResult<Usercomment>();
            pageListresult.code = 0;
            pageListresult.msg = "";
            pageListresult.count = count;
            pageListresult.data = list.Skip((page - 1) * limit).Take(limit).ToList();
            return Json(pageListresult, JsonRequestBehavior.AllowGet);
        }

        //删除用户点评
        public JsonResult Deletecomments(int id)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.Success = _userService.Deletecomments(id) > 0;
            return Json(responseResult, JsonRequestBehavior.AllowGet);

        }
    

        /// <summary>
        /// 借记卡提现
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public JsonResult CashOutBank(CashOutInfo cashOutInfo)
        {
            ResponseResult responseResult = new ResponseResult();
            //创建提现记录表对象
            CashOut cashOut = new CashOut();
            //属性赋值
            cashOut.User_Id = UserInfoContext.userInfoContext.UserInfo.User_Id;
            cashOut.CashOut_BankNum = cashOutInfo.CashOut_BankNum;
            cashOut.CashOut_From = cashOutInfo.CashOut_From;
            cashOut.CashOut_Money = cashOutInfo.CashOut_Money;
            cashOut.CashOut_Type = cashOutInfo.CashOut_Type;
            cashOut.CashOut_Name = cashOutInfo.CashOut_Name;
            cashOut.CashOut_CreateTime = DateTime.Now;
            //创建现金账号操作记录表对象
            Cashnumber_record cashnumber_Record = new Cashnumber_record();
            //属性赋值
            cashnumber_Record.Cash_Id = cashOutInfo.Cash_Id;
            cashnumber_Record.CashRecord_Money = cashOutInfo.CashOut_Money;
            cashnumber_Record.CashRecord_State = 0;
            cashnumber_Record.CashRecord_CreateTime = DateTime.Now;
            cashnumber_Record.CashRecord_Effective = DateTime.Now;
            cashnumber_Record.CashRecord_Channel = cashOutInfo.CashOut_From;
            cashnumber_Record.CashRecord_OperationMethod = "提现";
            //创建现金账号表对象
            Cashnumber cashnumber = new Cashnumber();
            cashnumber.Cash_balance = cashOutInfo.CashOut_Money;
            cashnumber.User_Id = UserInfoContext.userInfoContext.UserInfo.User_Id;
            //调用添加现金账号操作记录的方法
            responseResult = _userService.AddCashnumber_record(cashnumber_Record);
            //判断是否添加成功
            if (responseResult.Success) 
            {
                //查询新增的操作记录表主键Id
                Cashnumber_record cash = _userService.GetCashRecordLast().data;
                //赋值
                cashOut.CashRecord_Id = cash.CashRecord_Id;
                //调用添加提现记录的方法
                responseResult = _userService.AddCashOut(cashOut);
                if (responseResult.Success) 
                {
                    //调用修改现金账号余额的方法
                    responseResult = _userService.EditCashBalance(cashnumber);
                    if (responseResult.Success) 
                    {
                        //调用增加冻结金额方法
                        responseResult = _userService.AddCashFreeze(cashnumber);
                    }
                }
            }
            return Json(responseResult, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 兑换旅游卷
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult ExchangeTraVo(Cashnumber_record cashnumber_Record)
        {
            //创建返回结果类对象
            ResponseResult responseResult = new ResponseResult();
            //给现金账号记录表对象赋值
            cashnumber_Record.CashRecord_CreateTime = DateTime.Now;
            cashnumber_Record.CashRecord_Effective = DateTime.Now.AddDays(30);
            cashnumber_Record.CashRecord_State = 1;
            cashnumber_Record.CashRecord_OperationMethod = "兑换";
            cashnumber_Record.CashRecord_Channel = "旅游卷";
            //调用添加现金帐号操作记录表方法
            responseResult = _userService.AddCashnumber_record(cashnumber_Record);
            //判断是否成功
            if (responseResult.Success) 
            {
                //创建随机数生成卡密
                Random random = new Random();
                int pwd = random.Next(100000,999999);
                //创建旅游卷对象赋值
                Travelvo travelvo = new Travelvo();
                travelvo.TravelVo_balance = cashnumber_Record.CashRecord_Money;
                travelvo.TravelVo_CreateTime = DateTime.Now;
                travelvo.User_Id = UserInfoContext.userInfoContext.UserInfo.User_Id;
                travelvo.TravelVo_State = 1;
                travelvo.TravelVo_CardPwd = pwd.ToString();
                //调用添加旅游卷方法
                responseResult = _userService.AddTravelVo(travelvo);
                //判断是否成功
                if (responseResult.Success) 
                {
                    //查询新增的旅游卷Id
                    responseResult.data = _userService.GetTravelVoLast(travelvo).data;
                    travelvo = responseResult.data;
                    //创建旅游卷操作记录对象并赋值
                    Travelvo_record travelvo_Record = new Travelvo_record();
                    travelvo_Record.TravelVoRecord_Money = cashnumber_Record.CashRecord_Money;
                    travelvo_Record.TravelVoRecord_OperationMethod = "获取";
                    travelvo_Record.TravelVoRecord_CreateTime = DateTime.Now;
                    travelvo_Record.TravelVoRecord_Effective = DateTime.Now.AddDays(30);
                    travelvo_Record.TravelVo_Id = travelvo.TravelVo_Id;
                    responseResult = _userService.AddTravelVoRecord(travelvo_Record);
                    //判断是否成功
                    if (responseResult.Success) 
                    {
                        //创建现金账号对象赋值
                        Cashnumber cashnumber = new Cashnumber();
                        cashnumber.User_Id = UserInfoContext.userInfoContext.UserInfo.User_Id;
                        cashnumber.Cash_balance = cashnumber_Record.CashRecord_Money;
                        //调用修改现金账号余额方法
                        responseResult = _userService.EditCashBalance(cashnumber);
                    }
                }
            }
            return Json(responseResult);
        }

        /// <summary>
        /// 修改用户基本信息
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult EditUserInfo(UserInfo userInfo)
        {
            //通过Session给userInfo对象主键赋值
            userInfo.User_Id=UserInfoContext.userInfoContext.UserInfo.User_Id;
            //调用修改用户基本信息方法
            ResponseResult responseResult = _userService.EditUserInfo(userInfo);
            return Json(responseResult);
        }

        /// <summary>
        /// 修改用户手机号
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult EditUserTel(UserInfo userInfo)
        {
            //通过Session给userInfo对象主键赋值
            userInfo.User_Id = UserInfoContext.userInfoContext.UserInfo.User_Id;
            //调用修改用户手机号方法
            ResponseResult responseResult = _userService.EditUserTel(userInfo);
            return Json(responseResult);
        }

        /// <summary>
        /// 修改用户邮箱
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public JsonResult EditUserEmail(UserInfo userInfo)
        {
            //通过Session给userInfo对象主键赋值
            userInfo.User_Id = UserInfoContext.userInfoContext.UserInfo.User_Id;
            //调用修改用户手机号方法
            ResponseResult responseResult = _userService.EditUserEmail(userInfo);
            return Json(responseResult);
        }


        //支付方法
        public ActionResult Useristroute_Notice(string Order_Content,string Order_ProInfo,string Order_Money,string Order_No)
        {

            int userid = UserInfoContext.userInfoContext.UserInfo.User_Id != 0 ? UserInfoContext.userInfoContext.UserInfo.User_Id : 0;//没有读取到用户的id
            string UserID = userid.ToString();

            //开发者账号配置加载
            DefaultAopClient client = new DefaultAopClient(Config.gatewayUrl, Config.app_id, Config.private_key, "json", "1.0", Config.sign_type, Config.alipay_public_key, Config.charset, false);

            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();
            model.Body = Order_Content + "/" + UserID;// 商品描述
            model.Subject = Order_ProInfo; // 订单名称
            model.TotalAmount = Order_Money.ToString();// 付款金额
            model.OutTradeNo = Order_No; // 外部订单号，商户网站订单系统中唯一的订单号

            model.ProductCode = "FAST_INSTANT_TRADE_PAY";

            //model.PassbackParams = UserID;

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
            // 设置支付完成异步通知接收地址
            request.SetNotifyUrl("https://localhost:44336/PaymentRecord/AddPaymentRecord");//异步通知地址很重要，该异步页面主要用来支付成功后，进行相关的数据库操作

            // 设置支付完成同步回调地址
            request.SetReturnUrl("https://localhost:44336/Home/User_CashAccount?Order_Money=" + Order_Money);//支付成功后返回的地址
            request.SetBizModel(model);

            AlipayTradePagePayResponse response = null;
            try
            {
                response = client.PageExecute(request, null, "post");
                //Response.Write(response.Body);  原本无隐藏的初始代码
                string newhtml = "<div style=\"display:none\">" + response.Body + "</div>";//加这段将表单进行隐藏提交
                Response.Write(newhtml);
            }
            catch (Exception exp)
            {
                throw exp;
            }
            return View();
        }

        public ActionResult Useristroute_Notify()
        {
            Dictionary<string, string> sArray = GetRequestPost();

            if (sArray.Count != 0)
            {
                bool flag = AlipaySignature.RSACheckV1(sArray, Config.alipay_public_key, Config.charset, Config.sign_type, false);
                if (flag)
                {
                    //交易状态
                    //判断该笔订单是否在商户网站中已经做过处理
                    //如果没有做过处理，根据订单号（out_trade_no）在商户网站的订单系统中查到该笔订单的详细，并执行商户的业务程序
                    //请务必判断请求时的total_amount与通知时获取的total_fee为一致的
                    //如果有做过处理，不执行商户的业务程序

                    //注意：
                    //退款日期超过可退款期限后（如三个月可退款），支付宝系统发送该交易状态通知
                    string trade_status = Request.Form["trade_status"];

                    if (trade_status == "TRADE_SUCCESS")// 判断支付状态_交易成功
                    {
                        #region 获取相应的订单信息
                        //商户订单号
                        string out_trade_no = Request.Form["out_trade_no"];
                        //支付宝交易号
                        string trade_no = Request.Form["trade_no"];
                        //支付金额
                        decimal total_amount = Convert.ToDecimal(Request.Form["total_amount"].ToString());//ConvertType(Decimal.Zero);
                                                                                                          //实收金额
                                                                                                          //decimal receipt_amount = Request.Form["receipt_amount"].ConvertType(Decimal.Zero);
                                                                                                          //卖家支付宝账号
                        string seller_id = Request.Form["seller_id"];

                        //商品描述
                        string bodys = Request.Form["body"];
                        //body 商品描述
                        string body = "";
                        //用户id
                        string userid = "";
                        if (!string.IsNullOrEmpty(bodys))
                        {
                            string[] piont = bodys.Split('/');
                            body = piont[0];
                            userid = piont[1];
                        }//我这里用了个小聪明，把一个重要的数据库判断字段（用户的ID字段）加在了商品描述里，然后用/把两个字段分割开获取
                         //交易创建时间
                        DateTime gmt_create = DateTime.Parse(Request.Form["gmt_create"]);
                        //交易付款时间
                        DateTime gmt_payment = DateTime.Parse(Request.Form["gmt_payment"]);
                        //获取用户的id
                        int UserID = 0;
                        UserID = Convert.ToInt32(userid);

                        #endregion

                        #region 估价单付款成功的操作
                        if (body == "估价单付款")
                        {
                            //在数据库中提交估价单的订单信息

                        }

                    }
                    #endregion

                    Response.Write("success");
                }

            }
            else
            {
                Response.Write("fail");
            }

            return View();
        }

        public Dictionary<string, string> GetRequestPost()
        {
            int i = 0;
            Dictionary<string, string> sArray = new Dictionary<string, string>();
            NameValueCollection coll;
            //coll = Request.Form;
            coll = Request.QueryString;
            String[] requestItem = coll.AllKeys;
            for (i = 0; i < requestItem.Length; i++)
            {
                sArray.Add(requestItem[i], Request.Form[requestItem[i]]);
            }
            return sArray;

        }


        #region 绑定银行卡
        /// <summary>
        /// 绑定银行卡
        /// </summary>
        /// <param name="user_Bank"></param>
        /// <returns></returns>
        public JsonResult BindBank(User_Bank user_Bank)
        {
            //通过Session给User_Bank对象主键赋值
            user_Bank.User_Id = UserInfoContext.userInfoContext.UserInfo.User_Id;
            //调用绑定银行卡方法
            ResponseResult responseResult = _userService.BindBank(user_Bank);
            return Json(responseResult);
        }
        #endregion

        #region 解绑指定银行卡
        /// <summary>
        /// 解绑指定银行卡
        /// </summary>
        /// <param name="user_Bank"></param>
        /// <returns></returns>
        public JsonResult DelBank(User_Bank user_Bank)
        {
            //调用解绑指定银行卡方法
            ResponseResult responseResult = _userService.DelBank(user_Bank);
            return Json(responseResult);
        }
        #endregion
    }
}
